Addison Wesley: Modern C++ Design: Generic Programming and Design Patterns Applied by By
Author:By
Language: eng
Format: epub
ISBN: 0-201-70431-5
Publisher: Addison Wesley
Published: 2011-10-03T15:23:26.443977+00:00
6.10 Putting It All Together
This chapter has wandered around various possible implementations of Singleton, commenting on their relative strengths and weaknesses. The discussion doesn't lead to a unique implementation because the problem at hand is what dictates the best Singleton implementation.
The SingletonHolder class template defined by Loki is a Singleton container that assists you in using the Singleton design pattern. Following a policy-based design (see Chapter 1), SingletonHolder is a specialized container for a user-defined Singleton object. When using SingletonHolder, you pick the features needed, and maybe provide some code of your own. In extreme cases, you might still need to start all over again謡hich is okay, as long as those are indeed extreme cases.
This chapter visited quite a few issues that are mostly independent of each other. How, then, can Singleton implement so many cases without utter code bloating? The key is to decompose Singleton carefully into policies, as discussed in Chapter 1. By decomposing SingletonHolder into several policies, we can implement all the cases discussed previously in a small number of lines of code. By using template instantiation, you select the features needed and don't pay anything for the unneeded ones. This is important: The implementation of Singleton put together here is not the do-it-all class. Only the features used are ultimately included in the generated code. Plus, the implementation leaves room for tweaks and extensions.
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(11975)
Hello! Python by Anthony Briggs(9423)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(9388)
The Mikado Method by Ola Ellnestam Daniel Brolund(9352)
Dependency Injection in .NET by Mark Seemann(8896)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(7895)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(7413)
Grails in Action by Glen Smith Peter Ledbrook(7332)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(7161)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(6006)
Kotlin in Action by Dmitry Jemerov(4683)
Practical Vim (for Kathryn Amaral) by Drew Neil(3746)
Cracking the GRE Premium Edition with 6 Practice Tests, 2015 (Graduate School Test Preparation) by Princeton Review(3625)
Linux Device Driver Development Cookbook by Rodolfo Giometti(3532)
Learn Windows PowerShell in a Month of Lunches by Don Jones(3277)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(3188)
Microservices with Go by Alexander Shuiskov(2973)
Practical Design Patterns for Java Developers by Miroslav Wengner(2891)
Learning Java by Patrick Niemeyer & Daniel Leuck(2890)